<template>
  <div>
    <el-dialog
      title="编辑部门"
      :visible.sync="dialogshow"
      :before-close="dialogClose"
      style="display: none"
      :fullscreen="fullscreen"
    >
      <dialog-tools
        v-bind:back="true"
        v-bind:next="true"
        v-bind:goback="true"
        v-bind:prev="true"
        v-bind:screen="true"
        @clickfullscreen="clickfullscreen"
      >
      </dialog-tools>
      <div>
        <el-form
          ref="elForm"
          :model="form"
          
          size="medium"
          label-width="100px"
        >
        


 <el-form ref="form" :model="form" :rules="rules" label-width="100px">

        <!-- <el-form-item label="上级部门" prop="parentId">
</el-form-item> -->

          <el-form-item label="上级部门" prop="parentId">
            <el-cascader v-model="form.parentId" :options="parentIdOptions" 
            :props="{ checkStrictly: true }"
              :style="{width: '100%'}" placeholder="请选择上级部门" clearable></el-cascader>
          </el-form-item>

        
        <el-row class="item-50">

        <el-form-item label="部门名称" prop="deptName">
          <el-input v-model="form.deptName" placeholder="请输入部门名称" />
        </el-form-item>

 <el-form-item label="显示顺序" prop="orderNum">
          <el-input-number v-model="form.sort" placeholder="请输入显示顺序"  :min="1" :max="100" controls-position="right"/>
        </el-form-item>

        </el-row>
<el-row class="item-50">

        <el-form-item label="负责人" prop="leader">
          <el-input v-model="form.leader" placeholder="请输入负责人" />
        </el-form-item>
        <el-form-item label="联系电话" prop="phone">
          <el-input v-model="form.phone" placeholder="请输入联系电话" />
        </el-form-item>
                </el-row>
<el-row class="item-50">

        <el-form-item label="部门状态">
          <el-radio-group v-model="form.status">
                <el-radio :label="0">正常</el-radio>
                <el-radio :label="1">停用</el-radio>
          </el-radio-group>
        </el-form-item>
       
        
        </el-row>
      </el-form>
        
      </div>
      <div slot="footer" class="dialog-footer">
        <!-- <el-button @click="resetForm" style="float:left;margin-left:20px;">查看款号详情</el-button> -->
        <el-button @click="resetForm">重置</el-button>
        <el-button @click="dialogClose">取 消</el-button>
        <el-button type="primary" @click="alertopen">确定</el-button>
      </div>
    </el-dialog>
    <!-- <dialog-search-order
      v-bind:dialogshow="dialogSearchOrder"
      @dialog_close="dialogSearchOrder = !dialogSearchOrder"
    ></dialog-search-order> -->
  </div>
</template>
<style scoped>
</style>

<script>
module.exports = {
  methods: {
    dialogAdd() {
      console.log(123);
    },
    dialogClose() {
      this.$emit("dialog_close", 1);
    },
    clickfullscreen() {
      this.fullscreen = !this.fullscreen;
    },
    submitForm() {
      this.$refs["elForm"].validate((valid) => {
        if (!valid) return;
        // TODO 提交表单
      });
    },
    resetForm() {
      this.$refs["elForm"].resetFields();
    },
    alertopen() {
      this.$confirm("是否继续操作?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "操作成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
    // 表单重置
    resetForm() {
      this.form = {
        deptId: null,
        parentId: null,
        ancestors: null,
        deptName: null,
        orderNum: null,
        leader: null,
        phone: null,
        email: null,
        status: 0,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        sort:1,
      };
      this.resetForm("form");
    },
  },
  props: ["dialogshow"],
  data() {
    return {
      fullscreen: false,
      form: {
        deptId: null,
        parentId: null,
        ancestors: null,
        deptName: null,
        orderNum: null,
        leader: null,
        phone: null,
        email: null,
        status: 0,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        sort:1,
      },
      rules:{

      },
      parentIdOptions: [{
        "label": "柏铖艺术",
        "value": 1,
        "id": 114,
        "children": [{
          "label": "销售部",
          "value": 2,
          "id": 115
        }, {
          "label": "采购部",
          "value": 3,
          "id": 116
        }]
      },
            {
        "label": "水贝门店",
        "value": 4,
        "id": 114,
        "children": [{
          "label": "业务部",
          "value": 5,
          "id": 115
        }, {
          "label": "保安部",
          "value": 6,
          "id": 116
        }]}
      
      
      ],
     
    };
  },
  components: {
    "dialog-tools": "url:../tools/dialog-tools.vue",
    "dialog-search-order": "url:./search-order.vue",
  },
};
</script>
